package crypto

import "github.com/tjfoc/gmsm/x509"

//Key 基本密钥（包括公钥私钥）接口
type Key interface {
	//Bytes 获取二进制序列化值
	Bytes() []byte
	//SKI 获取密钥的唯一标识，每种算法有各自的标识计算方法，通常是密钥二进制的hash或变体
	SKI() []byte
	//IsSymmetric 是否是对称加密算法
	IsSymmetric() bool
	//IsPrivate 是否是私钥
	IsPrivate() bool
}

//PrivateKey 私钥接口，继承基本Key类型,
type PrivateKey interface {
	Key
	PublicKey() PublicKey
	Signer
}

//PublicKey 公钥接口
type PublicKey interface {
	Key
	Verifier
}

//KeyPair 密钥对
type KeyPair interface {
	PrivateKey
}

// Signer 签名接口
type Signer interface {
	// Sign a message and return the signature over the digest, or error on failure
	Sign(message []byte) ([]byte, error)
	//GetSignatureAlgorithm get signature algorithm
	GetSignatureAlgorithm() x509.SignatureAlgorithm
}

//Verifier 验签接口
type Verifier interface {
	Verify(msg []byte, sig []byte) (bool, error)
}

//Encryptor encryptor
type Encryptor interface {
	Encrypt(data []byte) ([]byte, error)
}

//Decryptor decryptor
type Decryptor interface {
	Decrypt(data []byte) ([]byte, error)
}
